/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.File;
import java.io.IOException;
import java.util.Locale;

import jxl.Sheet;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.biff.CountryCode;
import jxl.read.biff.BiffException;
/**
 *
 * @author Raul
 */
public class GestorExcel {
    private String inputFile;
    private Workbook libro;

    public GestorExcel(String inputFile) {
        this.inputFile = inputFile;
    }

    public void setInputFile(String inputFile) {
        this.inputFile = inputFile;
    }
    
    public void abrir() throws IOException {
         File inputWorkbook = new File(inputFile);
         WorkbookSettings wbSettings = new WorkbookSettings();
         wbSettings.setEncoding("ISO-8859-1");
         wbSettings.setLocale(new Locale("es", "ES"));
         wbSettings.setExcelDisplayLanguage("ES");
         wbSettings.setExcelRegionalSettings("ES"); 
         wbSettings.setCharacterSet(CountryCode.SPAIN.getValue());
         try {
             libro = Workbook.getWorkbook(inputWorkbook, wbSettings);
         } catch(BiffException e) {
             e.printStackTrace();
         }
         
    }
    
    public Sheet getHoja(int nroHoja){
        return libro.getSheet(nroHoja);
    }
    
    public Sheet getHoja(String nombreHoja){
        return libro.getSheet(nombreHoja);
    }
}
